package com.openbravo.pos.util;

import com.openbravo.pos.forms.AppLocal;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.LayoutStyle;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingUtilities;

public class SelectPrinter extends JDialog
{
  private String printservice;
  private boolean ok;
  private JLabel jLabel7;
  private JPanel jPanel1;
  private JPanel jPanel2;
  private JPanel jPanel8;
  private JComboBox jPrinters;
  private JButton jcmdCancel;
  private JButton jcmdOK;

  private SelectPrinter(Frame paramFrame, boolean paramBoolean)
  {
    super(paramFrame, paramBoolean);
  }

  private SelectPrinter(Dialog paramDialog, boolean paramBoolean)
  {
    super(paramDialog, paramBoolean);
  }

  public static SelectPrinter getSelectPrinter(Component paramComponent, String[] paramArrayOfString)
  {
    Window localWindow = SwingUtilities.windowForComponent(paramComponent);
    SelectPrinter localSelectPrinter;
    if ((localWindow instanceof Frame))
      localSelectPrinter = new SelectPrinter((Frame)localWindow, true);
    else
      localSelectPrinter = new SelectPrinter((Dialog)localWindow, true);
    localSelectPrinter.init(paramArrayOfString);
    localSelectPrinter.applyComponentOrientation(paramComponent.getComponentOrientation());
    return localSelectPrinter;
  }

  private void init(String[] paramArrayOfString)
  {
    initComponents();
    this.jPrinters.removeAllItems();
    this.jPrinters.addItem("(Default)");
    for (String str : paramArrayOfString)
      this.jPrinters.addItem(str);
    this.jPrinters.setSelectedIndex(0);
    getRootPane().setDefaultButton(this.jcmdOK);
    this.ok = false;
    this.printservice = null;
  }

  public boolean isOK()
  {
    return this.ok;
  }

  public String getPrintService()
  {
    return this.printservice;
  }

  private void initComponents()
  {
    this.jPanel8 = new JPanel();
    this.jPanel1 = new JPanel();
    this.jcmdOK = new JButton();
    this.jcmdCancel = new JButton();
    this.jPanel2 = new JPanel();
    this.jLabel7 = new JLabel();
    this.jPrinters = new JComboBox();
    setDefaultCloseOperation(2);
    setTitle(AppLocal.getIntString("form.selectprintertitle"));
    this.jPanel8.setLayout(new BorderLayout());
    this.jcmdOK.setIcon(new ImageIcon(getClass().getResource("/com/openbravo/images/button_ok.png")));
    this.jcmdOK.setText(AppLocal.getIntString("Button.OK"));
    this.jcmdOK.setMargin(new Insets(8, 16, 8, 16));
    this.jcmdOK.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        SelectPrinter.this.jcmdOKActionPerformed(paramActionEvent);
      }
    });
    this.jPanel1.add(this.jcmdOK);
    this.jcmdCancel.setIcon(new ImageIcon(getClass().getResource("/com/openbravo/images/button_cancel.png")));
    this.jcmdCancel.setText(AppLocal.getIntString("Button.Cancel"));
    this.jcmdCancel.setMargin(new Insets(8, 16, 8, 16));
    this.jcmdCancel.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        SelectPrinter.this.jcmdCancelActionPerformed(paramActionEvent);
      }
    });
    this.jPanel1.add(this.jcmdCancel);
    this.jPanel8.add(this.jPanel1, "After");
    getContentPane().add(this.jPanel8, "South");
    this.jLabel7.setText(AppLocal.getIntString("Label.MachinePrinter"));
    GroupLayout localGroupLayout = new GroupLayout(this.jPanel2);
    this.jPanel2.setLayout(localGroupLayout);
    localGroupLayout.setHorizontalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addContainerGap().addComponent(this.jLabel7, -2, 130, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jPrinters, -2, 165, -2).addContainerGap(30, 32767)));
    localGroupLayout.setVerticalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addContainerGap().addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel7).addComponent(this.jPrinters, -2, -1, -2)).addContainerGap(57, 32767)));
    getContentPane().add(this.jPanel2, "Center");
    Dimension localDimension = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((localDimension.width - 359) / 2, (localDimension.height - 176) / 2, 359, 176);
  }

  private void jcmdOKActionPerformed(ActionEvent paramActionEvent)
  {
    this.ok = true;
    this.printservice = ((String)this.jPrinters.getSelectedItem());
    dispose();
  }

  private void jcmdCancelActionPerformed(ActionEvent paramActionEvent)
  {
    dispose();
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.util.SelectPrinter
 * JD-Core Version:    0.6.0
 */